<template>
    <Table :columns="tableColumns" :data="data" v-bind="tableAttrs" v-on="tableEvent" ></Table>
</template>

<script>
import {cloneDeep} from "lodash";

export default {
    name: "ivTable",
    data() {
        return {}
    },
    props:{
        data: {
            default: () => {
                return []
            }
        },
        tableConfig:{
            default:()=>{
                return{}
            }
        }
    },
    computed:{
        //表格属性
        tableAttrs() {
            let tmpTableConfig = cloneDeep(this.tableConfig);
            this.$delete(tmpTableConfig,'columns');
            return tmpTableConfig;
        },
        //表格事件
        tableEvent() {
           return this.$listeners;
        },
        //动态设置列
        tableColumns() {
            let tmpTableConfig = cloneDeep(this.tableConfig);
            if(tmpTableConfig && tmpTableConfig.columns && tmpTableConfig.columns.length >0){
                return tmpTableConfig.columns;
            }else{
                return []
            }
        },
    },
}
</script>
